﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using SelfInfo.Models;
using System.Data.Entity.Infrastructure;
using System.Data.Entity;


namespace SelfInfo.Controllers
{
    public class RecodeController : Controller
    {
        private SelfInfoEntities SelfInfo = new SelfInfoEntities();

        public ActionResult Index()
        {
            IList<RECODE> item = SelfInfo.RECODE.ToList<RECODE>();

            return View(item);
        }

        public ActionResult Create()
        {

            return View();
        }

        [HttpPost]
        public ActionResult Create(RECODE item)
        {

            //example
            //创建teacher一个实体
            //ITEM t = new ITEM();
            //t.TYPE = item.type;
            //t.NAME = "BOOK";
            //e.ITEM.AddObject(item);
            ////写回数据库
            //e.SaveChanges();

            if (ModelState.IsValid)
            {
                SelfInfo.RECODE.AddObject(item);
                SelfInfo.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(item);

        }
    }
}
